<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version= "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes" encoding="UTF-8"/>

  <xsl:template match="/">
    <html lang="en">
      <body>
        <h1>Documentation for <xsl:value-of select="WorkbookName"/></h1>
        <h2>VBProject: <xsl:value-of select="VBProjectName"/></h2>
        <xsl:apply-templates/>
        
        <footer>generated with VBADoc version <xsl:value-of select="@Version"/></footer>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="Documents">
    <h3 id="Documents">Document (Worksheets)</h3>
    <xsl:apply-templates/>
  </xsl:template>
  
  <xsl:template match="ClassModules">
    <h3 id="ClassModules">Class Modules</h3>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="Modules">
    <h3 id="Modules">Code Modules</h3>
  </xsl:template>

  <xsl:template match="Forms">
    <h3 id="Forms">User Forms</h3>
  </xsl:template>
  
  <xsl:template match="Document|ClassModule|Module|Form">
    <!--div id="{<xsl:value-of select='Name'/>}"-->
    <div class="CodeModule" id="{generate-id()}">
      <b><xsl:value-of select="Name"/></b>
      <xsl:if test="CommentHead!=''">
          <xsl:apply-templates select="CommentHead" />
      </xsl:if>
    </div>
  </xsl:template>
  
  <xsl:template match="Sub|Function">
    <div id="">
      <b><xsl:value-of select="Name"/></b>
      <b>Declaration:</b><xsl:value-of select="Declaration"/>
      <xsl:if test="CommentHead!=''">
        <xsl:apply-templates select="CommentHead" />
      </xsl:if>
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="CommentHead">
    <em>
     <xsl:for-each select="Line">
       <xsl:value-of select="."/><br />
     </xsl:for-each>
    </em>
  </xsl:template>
  
</xsl:stylesheet>